import java.util.Scanner;

public class Test2 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int len1 = in.nextInt();
            int len2 = in.nextInt();
            in.nextLine();
            int[] hash = new int[100001];
            int max = 0;
            for (int i = 0; i < len1; i++) {
                int num = in.nextInt();
                hash[num] = 1;
                max = Math.max(max, num);
            }
            in.nextLine();
            for (int i = 0; i < len2; i++) {
                int num = in.nextInt();
                hash[num] = 1;
                max = Math.max(max, num);
            }
            int count = 0;
            for (int i = 0; i < 100001; i++) {
                if (hash[i] == 1) {
                    System.out.print(i);
                    count++;
                    if (count == len1 + len2) {
                        break;
                    }
                    System.out.print(" ");
                }
            }
        }
    }
}
